//
// Created by 王乐 on 2022/2/4.
//

#include "LeTransform.h"
#include "glm/gtc/matrix_transform.hpp"

LeTransform::LeTransform()
{
    m_Position = glm::vec3(0.0f, 0.0f, 0.0f);
    m_Rotation = glm::vec3(0.0f, 0.0f, 0.0f);
    m_Scale = glm::vec3(1.0f, 1.0f, 1.0f);
}

LeTransform::~LeTransform()
{

}

void LeTransform::setPosition(float posx, float posy, float posz)
{
    m_Position = glm::vec3(posx, posy, posz);
}

void LeTransform::setRotation(float rotx, float roty, float rotz)
{
    m_Rotation = glm::vec3(rotx, roty, rotz);
}

void LeTransform::setScale(float scalx, float scaly, float scalz)
{
    m_Scale = glm::vec3(scalx, scaly, scalz);
}

//void LeTransform::translate(float x, float y, float z, bool relative2Self)
//{
//
//}
//
//void LeTransform::rotate(float x, float y, float z, bool relative2Self)
//{
//
//}
//
//void LeTransform::rotateAround(glm::vec3 point, glm::vec3 axis, float angle)
//{
//
//}

glm::mat4 LeTransform::getModelMatrix()
{
    glm::mat4 model = glm::mat4(1.0f);
    model = glm::translate(model, m_Position);
    model = glm::rotate(model, m_Rotation.y, glm::vec3(0.0f, 1.0f, 0.0f));
    model = glm::rotate(model, m_Rotation.x, glm::vec3(1.0f, 0.0f, 0.0f));
    model = glm::rotate(model, m_Rotation.z, glm::vec3(0.0f, 0.0f, 1.0f));
    model = glm::scale(model, m_Scale);
    return model;
}
